package com.zdy.worldtion.utils;

import android.app.Dialog;
import android.content.Context;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;

import com.zdy.worldtion.R;


public class DialogUtil {
    /**
     * 加载进度弹窗
     *
     * @param context 上下文
     * @return dialog
     */
    public static Dialog showLoadingDialog(Context context) {
        Dialog loadingDialog = new Dialog(context, R.style.dialog_loading_style);
        View view = View.inflate(context, R.layout.loading_new_layout, null);
        // 设置自定义的布局
        loadingDialog.setContentView(view);
        //使得点击对话框外部不消失对话框
        loadingDialog.setCanceledOnTouchOutside(false);
        Window dialogWindow = loadingDialog.getWindow();
        WindowManager.LayoutParams lp = dialogWindow.getAttributes();
        lp.width = (int) (ScreenSizeUtils.getInstance(context).getScreenWidth() * 0.85f);
        lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
        lp.gravity = Gravity.CENTER;
        dialogWindow.setAttributes(lp);
        return loadingDialog;
    }
}
